package com.java.test.agent.module.feescale;

import com.java.test.agent.module.feescale.dto.AgentFeeScaleDTO;
import com.java.test.agent.module.feescale.vo.AgentFeeScaleVO;
import com.java.test.controller.BaseController;
import com.java.test.dto.PageResultDTO;
import com.java.test.dto.ResponseDTO;
import com.java.test.system.dto.LoginAccountInfo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;

/**
 * 代理费用Controller
 *
 * @author lijie1
 * @date 2020/6/30 0030
 */
@Slf4j
@RestController
@RequestMapping("/agent/agentFeeScale")
public class AgentFeeScaleController extends BaseController {

    private AgentFeeScaleService agentFeeScaleService;
    @Autowired
    public void setAgentInfoService(AgentFeeScaleService agentInfoService) {
        this.agentFeeScaleService = agentInfoService;
    }


    /**
     * 查询
     * @return
     */
    @RequestMapping(value = "/selectToEntity",method = RequestMethod.POST)
    public ResponseDTO<AgentFeeScaleVO> selectToEntity() {
        log.debug("----------代理默认费率修改查询----------");
        return agentFeeScaleService.getSelectToEntity();
    }

    /**
     * 修改
     * @return
     */
    @RequestMapping(value = "/update",method = RequestMethod.POST)
    public ResponseDTO<PageResultDTO<AgentFeeScaleVO>> update(@RequestBody @Valid AgentFeeScaleDTO DTO, HttpServletRequest request) {
        log.debug("----------代理默认费率修改----------");
        LoginAccountInfo user = (LoginAccountInfo) request.getSession().getAttribute("user");
        systemManageService.insertlogInfo(user.getLoginAccout(), user.getIp(), "代理管理-代理默认费率设置-代理默认费率修改");
        return agentFeeScaleService.update(DTO);
    }


}
